package com.springboot.demo.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @author wubc683
 * @desc
 * @date 2021-09-01 8:51
 */
@Data
@NoArgsConstructor
public class Inbox {
    @ApiModelProperty("消息id")
    private Long id;
    @ApiModelProperty("消息所有者id")
    private Long ownerId;
    @ApiModelProperty("消息类型")
    private Integer type;
    @ApiModelProperty("通知内容,根据消息通信码解析消息内容")
    private String content;
    @ApiModelProperty("websocket通信码，表示前端websocket收到的消息是收件箱消息")
    private Integer code;
    @ApiModelProperty(value = "消息状态,1表示已读，0表示未读")
    private Integer readed;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("消息创建日期")
    private Date createDate;
    @ApiModelProperty(value = "是否需要用户回应,0表示消息不用回应，1表示需要用户回应，即页面需要在消息内容后面增加同意或拒绝选项给用户，" +
            "让用户选择是否同意该消息的申请操作，" + "例如：消息内容：xxx申请加入设备群，同意/拒绝？页面要加上选择按钮：同意、拒绝")
    private Boolean needReply = false;
    @ApiModelProperty(value = "消息回复状态,needReply字段为true,该字段才有意义,表示该消息的回复状态,0表示用户未回应，" +
            "1表示用户已同意，2表示已拒绝")
    private Integer replyState;
    @ApiModelProperty(value = "消息回复，使用此url，消息体模板:{\"msgId\":111,\"ansCode\":1},msgId为此消息id，" +
            "ansCode为回复码，1表示同意，2表示拒绝")
    private String replyUrl;
    @ApiModelProperty(value = "消息加密数据,前端忽略")
    private String encryptData;

    public Inbox(Long uid,Integer type, Integer code,String content) {
        this.ownerId = uid;
        this.type = type;
        this.code = code;
        this.content = content;
        this.readed = 0;
        this.createDate = new Date();
        this.needReply = false;
        this.replyState = null;
        this.replyUrl = null;
        this.encryptData = null;
    }
}
